﻿Public Class EditorOptionPage
    Inherits OptionPage
    Friend WithEvents FlatTabs As System.Windows.Forms.CheckBox
    Friend WithEvents ShowLineNumbers As System.Windows.Forms.CheckBox

    Public Sub New()
        InitializeComponent()
    End Sub

    Public Overrides Sub OnApplySettings()

        If FlatTabs.Checked Then
            MainForm.EditorTabManager.TabControl.Appearance = TabAppearance.FlatButtons
        Else
            MainForm.EditorTabManager.TabControl.Appearance = TabAppearance.Normal
        End If

        Globals.UISettings.SetTrait(Of Boolean)("FlatTabs", FlatTabs.Checked)

        For Each etab In MainForm.EditorTabManager.TabPages
            Dim editortab As EditorTabPage =
                CType(etab, EditorTabPage)

            editortab.ScintillaEditor.LineNumbers = ShowLineNumbers.Checked
            Globals.EditorSettings.SetTrait(Of Boolean)("LineNumbers", ShowLineNumbers.Checked)
        Next

    End Sub

    Public Overrides Sub OnLoadSettings()
        Dim flattab As Boolean =
            Globals.UISettings.GetTrait(Of Boolean)("FlatTabs", True)

        FlatTabs.Checked = flattab

        Dim linenumbers As Boolean =
            Globals.EditorSettings.GetTrait(Of Boolean)("LineNumbers", True)

        ShowLineNumbers.Checked = linenumbers

    End Sub

    Private Sub InitializeComponent()
        Me.ShowLineNumbers = New System.Windows.Forms.CheckBox()
        Me.FlatTabs = New System.Windows.Forms.CheckBox()
        Me.SuspendLayout()
        '
        'ShowLineNumbers
        '
        Me.ShowLineNumbers.Location = New System.Drawing.Point(10, 10)
        Me.ShowLineNumbers.Name = "ShowLineNumbers"
        Me.ShowLineNumbers.Size = New System.Drawing.Size(200, 24)
        Me.ShowLineNumbers.TabIndex = 0
        Me.ShowLineNumbers.Text = "Show Line Numbers"
        Me.ShowLineNumbers.UseVisualStyleBackColor = True
        '
        'FlatTabs
        '
        Me.FlatTabs.Location = New System.Drawing.Point(10, 30)
        Me.FlatTabs.Name = "FlatTabs"
        Me.FlatTabs.Size = New System.Drawing.Size(150, 24)
        Me.FlatTabs.TabIndex = 1
        Me.FlatTabs.Text = "Use Flat Tabs"
        Me.FlatTabs.UseVisualStyleBackColor = True
        '
        'EditorOptionPage
        '
        Me.Controls.Add(Me.ShowLineNumbers)
        Me.Controls.Add(Me.FlatTabs)
        Me.Text = "Editor"
        Me.ResumeLayout(False)

    End Sub

End Class
